<template>
  <el-card v-if="countData" shadow="never" header="数据统计" class="count-panel">
    <div class="count_box">
      <CountCard title="用户数量" :value="countData.user" color="#2989ff">
        <img src="@/assets/icons/count-user.png" class="icon" />
      </CountCard>

      <CountCard title="在线设备" :value="countData.devicesOnline" color="#ffa823">
        <img src="@/assets/icons/count-devicesOnline.png" class="icon" />
      </CountCard>

      <CountCard title="设备数量" :value="countData.devices" color="#fb5c55">
        <img src="@/assets/icons/count-devices.png" class="icon" />
      </CountCard>
      <CountCard title="离线设备" :value="countData.devicesOffline" color="#01b9c1">
        <img src="@/assets/icons/count-devicesOffline.png" class="icon" />
      </CountCard>

      <CountCard title="总施工订单" :value="countData.order" color="#2989ff" icon="count-order.png">
        <img src="@/assets/icons/count-devicesOffline.png" class="icon" />
      </CountCard>

      <CountCard title="改造档案" :value="countData.archives" color="#ffa823">
        <img src="@/assets/icons/count-archives.png" class="icon" />
      </CountCard>

      <CountCard title="待施工订单" :value="countData.orderConstruction" color="#fb5c55">
        <img src="@/assets/icons/count-orderConstruction.png" class="icon" />
      </CountCard>

      <CountCard title="待审核用户档案" :value="countData.archivesAudit" color="#01b9c1">
        <img src="@/assets/icons/count-archivesAudit.png" class="icon" />
      </CountCard>

      <CountCard title="待处理改造账单" :value="countData.bill" color="#2989ff">
        <img src="@/assets/icons/count-bill.png" class="icon" />
      </CountCard>

      <CountCard title="工人数量" :value="countData.worker" color="#ffa823">
        <img src="@/assets/icons/count-worker.png" class="icon" />
      </CountCard>
    </div>
  </el-card>
</template>

<script setup lang="ts">
import CountAPI, { CountDataModel } from "@/api/count";
import CountCard from "./count-card.vue";

const countData = ref<CountDataModel>();

onMounted(() => {
  fetchData();
});

function fetchData() {
  CountAPI.countData().then((res) => {
    countData.value = res;
  });
}
</script>

<style lang="scss" scoped>
.count_box {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-gap: 15px;

  .icon {
    width: 40px;
    height: 40px;
  }
}
</style>
